/* 
 * Copyright (C) 2015 Federico Migliavacca, Leonardo Orsello
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package Boundary;

import Entity.RegisteredUser;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import org.primefaces.model.DefaultScheduleEvent;

/**
 *
 * @author fede
 */
public class EventMod extends DefaultScheduleEvent implements Serializable {

    /**
     * location
     */
    public String location;

    /**
     * indoor_bool
     */
    public Boolean indoor_bool;

    /**
     * public_bool
     */
    public Boolean public_bool;

    /**
     * owner
     */
    public String owner;

    /**
     * description if weather
     */
    public String descriptionW;

    /**
     * temperature of weather
     */
    public Float temperatureW;

    /**
     * icon of weather
     */
    public String iconW;

    /**
     * showDetail
     */
    public Boolean showDetail;

    /**
     * hasWeather
     */
    public Boolean hasWeather;
    private List<RegisteredUser> guest;

    /**
     * this method get Description of event
     *
     * @return description as string
     */
    public String getDescriptionW() {
        return descriptionW;
    }

    /**
     * this method set Description of event
     *
     * @param descriptionW String
     */
    public void setDescriptionW(String descriptionW) {
        this.descriptionW = descriptionW;
    }

    /**
     * this method get temperature of weather
     *
     * @return Float
     */
    public Float getTemperatureW() {
        return temperatureW;
    }

    /**
     * this method set temperature of weather
     *
     * @param temperatureW Float
     */
    public void setTemperatureW(Float temperatureW) {
        this.temperatureW = temperatureW;
    }

    /**
     * this method get Icon of weather
     *
     * @return String
     */
    public String getIconW() {
        return iconW;
    }

    /**
     * this method set temperature of weather
     *
     * @param iconW String
     */
    public void setIconW(String iconW) {
        this.iconW = "http://openweathermap.org/img/w/" + iconW + ".png";
    }

    /**
     * this method get Location of Event
     *
     * @return String
     */
    public String getLocation() {
        return location;
    }

    /**
     * this method set Location of Event
     *
     * @param location String
     */
    public void setLocation(String location) {
        this.location = location;
    }

    /**
     * this method get the indoor or outdoor for event
     *
     * @return boolean value
     */
    public Boolean getIndoor_bool() {
        return indoor_bool;
    }

    /**
     * this method set the indoor or outdoor for event
     *
     * @param indoor_bool indoor=true, outdoor=false
     */
    public void setIndoor_bool(Boolean indoor_bool) {
        this.indoor_bool = indoor_bool;
    }

    /**
     * this method get the public or private visibility of event
     *
     * @return boolean value
     */
    public Boolean getPublic_bool() {
        return public_bool;
    }

    /**
     * this method set the public or private visibility to event
     *
     * @param public_bool public=true, private=false
     */
    public void setPublic_bool(Boolean public_bool) {
        this.public_bool = public_bool;
    }

    /**
     * this method allow to get all invited user for the current event
     *
     * @return the invited users as a list
     */
    public List<RegisteredUser> getGuest() {
        return guest;
    }

    /**
     * this method allow to set all invited user for the current event
     *
     * @param guest list of RegisteredUser invited to an event
     */
    public void setGuest(List<RegisteredUser> guest) {
        this.guest = guest;
    }

    /**
     * this method allow to set an invited user for the current event
     *
     * @param guest RegisteredUser invited to an event
     */
    public void addGuest(RegisteredUser guest) {
        this.guest.add(guest);
    }

    /**
     * This method return true if event has Id
     *
     * @return boolean true=has ID
     */
    public Boolean hasId() {
        return this.getId() != null;
    }

    /**
     * This method return the status of field showDetail
     *
     * @return boolean
     */
    public Boolean getShowDetail() {
        return showDetail;
    }

    /**
     * This method set the status of field showDetail
     *
     * @param showDetail boolean
     */
    public void setShowDetail(Boolean showDetail) {
        this.showDetail = showDetail;
    }

    /**
     * this method allow to get the owner of the current event
     *
     * @return owner of event
     */
    public String getOwner() {
        return owner;
    }

    /**
     * This method give true if event has weather
     *
     * @return boolean
     */
    public Boolean getHasWeather() {
        return hasWeather;
    }

    /**
     * this method set the parameter hasWeather
     *
     * @param hasWeather boolean
     */
    public void setHasWeather(Boolean hasWeather) {
        this.hasWeather = hasWeather;
    }

    /**
     * constructor
     */
    public EventMod() {
    }

    /**
     * constructor
     *
     * @param eventId string
     */
    public EventMod(String eventId) {
        this.setId(eventId);
    }

    /**
     *
     * @param title string
     * @param start date
     * @param end date
     */
    public EventMod(String title, Date start, Date end) {
        super(title, start, end);
    }

    /**
     * constructor
     *
     * @param title string
     * @param start date
     * @param end date
     * @param allDay boolean
     */
    public EventMod(String title, Date start, Date end, boolean allDay) {
        super(title, start, end, allDay);
    }

    /**
     * constructor
     *
     * @param title string
     * @param start date
     * @param end date
     * @param styleClass string
     */
    public EventMod(String title, Date start, Date end, String styleClass) {
        super(title, start, end, styleClass);
    }

    /**
     * constructor
     *
     * @param title string
     * @param start date
     * @param end date
     * @param data object
     */
    public EventMod(String title, Date start, Date end, Object data) {
        super(title, start, end, data);
    }

    /**
     * constructor
     *
     * @param location string
     * @param indoor_bool boolean
     * @param public_bool boolean
     * @param title string
     * @param start date
     * @param end date
     * @param description string
     * @param allDay boolean
     * @param isEditable boolean
     * @param guest List of registered User
     * @param showDetail boolean
     * @param owner Registered User
     */
    public EventMod(String location, Boolean indoor_bool,
            Boolean public_bool, String title, Date start,
            Date end, String description, boolean allDay,
            Boolean isEditable, List<RegisteredUser> guest,
            Boolean showDetail, RegisteredUser owner) {

        super(title, start, end, allDay);
        super.setDescription(description);
        this.location = location;
        this.indoor_bool = indoor_bool;
        this.public_bool = public_bool;
        this.setEditable(isEditable);
        this.guest = guest;
        this.showDetail = showDetail;
        this.owner = owner.getName() + " " + owner.getSurname() + " (" + owner.getEmail() + ")";
        this.hasWeather = false;
    }

    /**
     * constructor
     *
     * @param location string
     * @param indoor_bool boolean
     * @param public_bool boolean
     * @param title string
     * @param start date
     * @param end date
     * @param description string
     * @param allDay boolean
     * @param descriptionW string
     * @param temperatureW float
     * @param iconW string
     * @param isEditable boolean
     * @param guest List of Registered user
     * @param showDetail String
     * @param owner Registered user
     */
    public EventMod(String location, Boolean indoor_bool,
            Boolean public_bool, String title, Date start,
            Date end, String description, boolean allDay,
            String descriptionW, Float temperatureW, String iconW,
            Boolean isEditable, List<RegisteredUser> guest,
            Boolean showDetail, RegisteredUser owner) {

        super(title, start, end, allDay);
        super.setDescription(description);
        this.location = location;
        this.indoor_bool = indoor_bool;
        this.public_bool = public_bool;
        this.iconW = "http://openweathermap.org/img/w/" + iconW + ".png";
        this.temperatureW = temperatureW;
        this.descriptionW = descriptionW;
        this.hasWeather = true;
        this.setEditable(isEditable);
        this.guest = guest;
        this.showDetail = showDetail;
        this.owner = owner.getName() + " " + owner.getSurname() + " (" + owner.getEmail() + ")";
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final EventMod other = (EventMod) obj;
        if (!Objects.equals(super.getId(), other.getId())) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + Objects.hashCode(super.getId());
        return hash;
    }

}
